#ifndef _SEARCHENGINESERVER_H__
#define _SEARCHENGINESERVER_H__

#include "./../RecommendWords/KeyRecommender.h"
#include "./../Reactor/TcpServer.h"
#include "./../Reactor/TcpConnection.h"
#include "./../Reactor/ThreadPool.h"
#include "./../Tools/Configuration.h"

class SearchEngineServer
{
public:
    SearchEngineServer(size_t threadNum,size_t quesize,const string& ip,unsigned int port);
    ~SearchEngineServer();

    // 服务器的启动与停止
    void start();
    void stop();
    
private:
    // 所有的回调
    void onNewConnection(const TcpConnectionPtr& con);
    void onMessage(const TcpConnectionPtr& con);
    void onClose(const TcpConnectionPtr& con);

    // 业务逻辑的处理
    void doTaskThread(const TcpConnectionPtr& con,const string& msg);

private:
    ThreadPool _pool;
    TcpServer _tcpserver;
};

#endif
